package com.medusa.aps.business.model.enums;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum ProductionType {


    /**
     * 外购
     */
    OUTSIDE_PURCHASE(1, "外购"),

    /**
     * 自制
     */
    SELF_MADE(2, "自制"),

    /**
     * 委外
     */
    OUTSOURCING(3, "委外"),
    ;

    @EnumValue
    private final Integer value;

    @JSONField(value = true)
    private final String desc;

    ProductionType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static ProductionType getByDesc(String desc) {
        for (ProductionType productionType : ProductionType.values()) {
            if (productionType.getDesc().equals(desc)) {
                return productionType;
            }
        }
        return null;
    }
}
